﻿@model List<YahooFinanceWatcher.Models.CompanyInfo>

<div class="table-responsive">
	@if (Model.Any())
    {
        <button type="button" id="btnRefreshSymbol" class="btn btn-default" onclick="RefreshSymbols()">Refresh</button>
		<table class="table table-bordered tablesorter">
			<thead>
				<tr>
                    <th><a href="#">Symbol</a></th>

					<th><a href="#">Prev Close</a></th>
					<th><a href="#">Open</a></th>
                    <th><a href="#">Bid</a></th>
					<th><a href="#">Ask</a></th>
					<th><a href="#">1y Target Est</a></th>
                    <th><a href="#">Beta</a></th>
					<th><a href="#">Next Earnings Date</a></th>

                    <th><a href="#">Day's Range</a></th>
					<th><a href="#">52wk Range</a></th>
                    <th><a href="#">Volume</a></th>
					<th><a href="#">Avg Vol (3m)</a></th>
					<th><a href="#">Market Cap</a></th>
                    <th><a href="#">P/E (ttm)</a></th>
					<th><a href="#">EPS (ttm)</a></th>
                    <th><a href="#">Div & Yield</a></th>
                    <th></th>
				</tr>
			</thead>
			<tbody>
				@foreach (var item in Model)
    {
					<tr>
                        <td><a href="@item.Url">@item.Symbol</a></td>

						<td>@item.PrevClose</td>
                        <td>@item.Open</td>
                        <td>@item.Bid</td>
                        <td>@item.Ask</td>
                        <td>@item.TargetEst</td>
                        <td>@item.Beta</td>
                        <td>@item.NextEarningsDate</td>

                        <td>@item.DaysRange</td>
                        <td>@item.Wk52Range</td>
                        <td>@item.Volume</td>
                        <td>@item.AvgVol3m</td>
                        <td>@item.MarketCap</td>
                        <td>@item.PE</td>
                        <td>@item.EPS</td>
                        <td>@item.Div</td>
                        <td align="center">
                            @using (Html.BeginForm("DeleteSymbol", "Home", new { symbol = item.Symbol, portfolioId = item.PortfolioId }, FormMethod.Post, new { @class = "form-horizontal", id = "formDelete", style = "display:inline;" }))
                            {
                                <a href="#" class="remove_symbol_lnk"><img src="@Url.Content("~/Content/Images/delete.png")" alt="" title="Delete symbol" border="0" /></a>
                            }
                        </td>
					</tr>
    }
			</tbody>
		</table>
    }
 else
 {
		<p>No records found.</p>
 }
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $(".remove_symbol_lnk").click(function (e) {
            e.preventDefault();

            var form = $(this).closest("form");

            if ($(form).valid()) {
                if (confirm('Do you want delete Symbol?'))
                    form.submit();
            }
        });
    });

</script>
